home *** CD-ROM | disk | FTP | other *** search
/ The Utilities Experience / The Utilities Experience - Volume 1.iso / software / misc / o-z / x-windows / mesa-amiwin / src / xform.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-30  |  3.7 KB  |  131 lines

  1. /* xform.h */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  1.2
  6.  * Copyright (C) 1995  Brian Paul  (brianp@ssec.wisc.edu)
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25. $Id: xform.h,v 1.12 1995/09/27 18:30:44 brianp Exp $
  26.  
  27. $Log: xform.h,v $
  28.  * Revision 1.12  1995/09/27  18:30:44  brianp
  29.  * added gl_transform_normals
  30.  *
  31.  * Revision 1.11  1995/09/26  16:05:08  brianp
  32.  * removed gl_transform_point, gl_transform_normal
  33.  * added gl_transform_points
  34.  *
  35.  * Revision 1.10  1995/09/13  14:46:18  brianp
  36.  * changed TRANSFORM_POINT and TRANSFORM_NORMAL macros
  37.  * removed TRANSFORM_XYZW macro
  38.  *
  39.  * Revision 1.9  1995/07/25  16:42:34  brianp
  40.  * added TRANSFORM_XYZW macro
  41.  *
  42.  * Revision 1.8  1995/06/02  18:52:50  brianp
  43.  * replaced 0.00001 with 0.00001F (avoid a double/float conversion)
  44.  *
  45.  * Revision 1.7  1995/05/22  20:59:34  brianp
  46.  * Release 1.2
  47.  *
  48.  * Revision 1.6  1995/03/24  17:01:15  brianp
  49.  * removed assert() call
  50.  *
  51.  * Revision 1.5  1995/03/10  15:20:06  brianp
  52.  * added divide by zero check to TRANSFORM_NORMAL
  53.  *
  54.  * Revision 1.4  1995/03/09  21:42:45  brianp
  55.  * new ModelViewInv matrix logic
  56.  *
  57.  * Revision 1.3  1995/03/09  20:08:39  brianp
  58.  * introduced TRANSFORM_POINT and TRANSFORM_NORMAL macros
  59.  *
  60.  * Revision 1.2  1995/03/04  19:25:29  brianp
  61.  * 1.1 beta revision
  62.  *
  63.  * Revision 1.1  1995/02/24  14:28:31  brianp
  64.  * Initial revision
  65.  *
  66.  */
  67.  
  68.  
  69. #ifndef XFORM_H
  70. #define XFORM_H
  71.  
  72.  
  73. #include "context.h"
  74.  
  75.  
  76. /* Map NDC coords to window coords: */
  77. #define MAP_X( X )    ( (X) * CC.Viewport.Sx + CC.Viewport.Tx )
  78. #define MAP_Y( Y )    ( (Y) * CC.Viewport.Sy + CC.Viewport.Ty )
  79. #define MAP_Z( Z )    ( (Z) * CC.Viewport.Sz + CC.Viewport.Tz )
  80.  
  81.  
  82.  
  83. /*
  84.  * Transform a point (column vector) by a matrix:   Q = M * P
  85.  */
  86. #define TRANSFORM_POINT( Q, M, P )                    \
  87.    Q[0] = M[0] * P[0] + M[4] * P[1] + M[8] *  P[2] + M[12] * P[3];    \
  88.    Q[1] = M[1] * P[0] + M[5] * P[1] + M[9] *  P[2] + M[13] * P[3];    \
  89.    Q[2] = M[2] * P[0] + M[6] * P[1] + M[10] * P[2] + M[14] * P[3];    \
  90.    Q[3] = M[3] * P[0] + M[7] * P[1] + M[11] * P[2] + M[15] * P[3];
  91.  
  92.  
  93. /*
  94.  * Transform a normal (row vector) by a matrix:  [NX NY NZ] = N * MAT
  95.  */
  96. #define TRANSFORM_NORMAL( NX, NY, NZ, N, MAT )        \
  97.    NX = N[0] * MAT[0] + N[1] * MAT[1] + N[2] * MAT[2];    \
  98.    NY = N[0] * MAT[4] + N[1] * MAT[5] + N[2] * MAT[6];    \
  99.    NZ = N[0] * MAT[8] + N[1] * MAT[9] + N[2] * MAT[10];    \
  100.  
  101.  
  102.  
  103. extern void gl_transform_points( GLuint n, GLfloat q[][4], const GLfloat m[16],
  104.                                  GLfloat p[][4] );
  105.  
  106.  
  107. extern void gl_transform_normals( GLuint n, GLfloat v[][3],
  108.                                   const GLfloat m[16],
  109.                                   GLfloat u[][3], GLboolean normalize );
  110.  
  111.  
  112. extern void gl_transform_vector( GLfloat u[4],
  113.                  const GLfloat v[4], const GLfloat m[16] );
  114.  
  115.  
  116. extern void gl_compute_modelview_inverse( void );
  117.  
  118.  
  119. extern void gl_load_matrix( const GLfloat *m );
  120.  
  121. extern void gl_mult_matrix( const GLfloat *m );
  122.  
  123. extern void gl_viewport( GLint x, GLint y, GLsizei width, GLsizei height );
  124.  
  125. extern void gl_compute_viewport( struct gl_context *c,
  126.                  GLint x, GLint y,
  127.                  GLsizei width, GLsizei height );
  128.  
  129.  
  130. #endif
  131.